using Perfect.Marshal;
using System.Xml;

namespace editor
{
namespace cfg.skill
{
[System.Serializable]
public  class AttackSegment : Segment
 {

    public cfg.skill.HitArea hitArea ;
     public cfg.role.RelationType targetType ;
     public cfg.skill.HitPointAction hitPointAction ;
     


    public const int TYPE_ID = 219912636;

    public override int GetTypeId() {
        return TYPE_ID;
    }


    public override void MarshalCompatible(Perfect.Marshal.Octets os) {
        os.WriteSize(5);
        os.WriteSize(Tag.FLOAT | (1 << Tag.TAG_SHIFT));  os.WriteFloat(startTime);  
         os.WriteSize(Tag.FLOAT | (2 << Tag.TAG_SHIFT));  os.WriteFloat(duration);  
         os.WriteSize(Tag.BEAN | (3 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_cfg_skill_HitArea(hitArea,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.INT | (4 << Tag.TAG_SHIFT));  os.WriteInt((int)targetType);  
         os.WriteSize(Tag.BEAN | (5 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_cfg_skill_HitPointAction(hitPointAction,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         
    }

    public override void UnmarshalCompatible(Perfect.Marshal.Octets os) {
        for (int _var_num_ = os.ReadSize(); _var_num_-- > 0; ) {
            int _id_ = os.ReadSize();
            switch (_id_)
            {
            case (Tag.FLOAT | (1 << Tag.TAG_SHIFT)):   startTime = os.ReadFloat(); break;  
             case (Tag.FLOAT | (2 << Tag.TAG_SHIFT)):   duration = os.ReadFloat(); break;  
             case (Tag.BEAN | (3 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); hitArea = cfg.Extensions.unmarshal_compatible_cfg_skill_HitArea(os); os = _oldOs; break; }   
             case (Tag.INT | (4 << Tag.TAG_SHIFT)):   targetType = (cfg.role.RelationType)(os.ReadInt()); break;  
             case (Tag.BEAN | (5 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); hitPointAction = cfg.Extensions.unmarshal_compatible_cfg_skill_HitPointAction(os); os = _oldOs; break; }   
             
            default: Tag.SkipUnknownField(_id_, os); break;
            }
         }
    }
    public override void MarshalXml(XmlWriter ele)
    {
        ele.WriteAttributeString("type", "AttackSegment");
        ele.WriteStartElement("startTime"); ele.WriteAttributeString("id", "1"); ele.WriteFloat(startTime); ele.WriteEndElement();
         ele.WriteStartElement("duration"); ele.WriteAttributeString("id", "2"); ele.WriteFloat(duration); ele.WriteEndElement();
         ele.WriteStartElement("hitArea"); ele.WriteAttributeString("id", "3"); cfg.Extensions.xml_marshal_cfg_skill_HitArea(hitArea,ele); ele.WriteEndElement();
         ele.WriteStartElement("targetType"); ele.WriteAttributeString("id", "4"); ele.WriteEnum(targetType); ele.WriteEndElement();
         ele.WriteStartElement("hitPointAction"); ele.WriteAttributeString("id", "5"); cfg.Extensions.xml_marshal_cfg_skill_HitPointAction(hitPointAction,ele); ele.WriteEndElement();
         
    }

    public override void UnmarshalXml(XmlElement ele)
    {
        foreach (XmlElement e in ele.GetChildren())
        {
            if (int.TryParse(ele.GetAttribute("id"), out var _id_))
            {
                switch (_id_)
                {
                case 1:  startTime = ele.ReadFloat(); break; 
                 case 2:  duration = ele.ReadFloat(); break; 
                 case 3:  hitArea = cfg.Extensions.xml_unmarshal_cfg_skill_HitArea(ele); break; 
                 case 4:  targetType = ele.ReadEnum<cfg.role.RelationType>(); break; 
                 case 5:  hitPointAction = cfg.Extensions.xml_unmarshal_cfg_skill_HitPointAction(ele); break; 
                 
                default: break;
                }
            }
            else
            {
                switch (e.Name)
                {
                case "start_time":  startTime = ele.ReadFloat(); break; 
                 case "duration":  duration = ele.ReadFloat(); break; 
                 case "hit_area":  hitArea = cfg.Extensions.xml_unmarshal_cfg_skill_HitArea(ele); break; 
                 case "target_type":  targetType = ele.ReadEnum<cfg.role.RelationType>(); break; 
                 case "hit_point_action":  hitPointAction = cfg.Extensions.xml_unmarshal_cfg_skill_HitPointAction(ele); break; 
                 
                default: break;
                }
            }
        }
    }
}
}
}
